package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormDiskInDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormDiskInDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormDiskInDetailConverter {

    public static FlowFormDiskInDetailDto do2Dto(FlowFormDiskInDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormDiskInDetailDto dto = FlowFormDiskInDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormDiskInDetailDto> do2Dto(List<FlowFormDiskInDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormDiskInDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormDiskInDetail dto2Do(FlowFormDiskInDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormDiskInDetail domain = FlowFormDiskInDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormDiskInDetail> dto2Do(List<FlowFormDiskInDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormDiskInDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormDiskInDetailMapper {

        FlowFormDiskInDetailMapper INSTANCE = Mappers.getMapper(FlowFormDiskInDetailMapper.class);

        FlowFormDiskInDetailDto do2Dto(FlowFormDiskInDetail domain);

        List<FlowFormDiskInDetailDto> do2Dto(List<FlowFormDiskInDetail> domain);

        FlowFormDiskInDetail dto2Do(FlowFormDiskInDetailDto dto);

        List<FlowFormDiskInDetail> dto2Do(List<FlowFormDiskInDetailDto> dto);
    }
}
